<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="pc/include :: header('专题')" />

    <link th:href="@{/js/ui-table/ui-table.css}" rel="stylesheet"/>
</head>
<body>
<th:block th:include="pc/include :: top" />
<div class="iw">
    <div class="crumbs">
        <p>当前位置：<a href="/">首页</a> > <a href="#">专题</a> > 编辑评论</p>
    </div>
    <div class="comment-edit">
        <label>评论 : <a href='#' th:text="${topic_title}"></a></label>
        <script id="editor" name='word' type="text/plain">[(${comment.comment})]</script>
        <div class="btn">提交</div>
    </div>
</div>
<th:block th:include="pc/include :: footer" />
<script type="text/javascript">
    var ctxPath= "[[${#httpServletRequest.getContextPath()}]]";
    window.CTX = ctxPath;
</script>
<link type="text/css" th:href="@{/js/ui-editor/ui-editor.css}" rel="stylesheet" />
<script type="text/javascript" charset="utf-8" th:src="@{/js/neditor/neditor.config.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/js/neditor/neditor.all.js}"></script>
<script>
    $(function() {

        var ue = UE.getEditor('editor', {
            initialFrameHeight: 200,
            initialFrameWidth: '100%',
            serverUrl: window.CTX + "/ueditor/config",
            elementPathEnabled: false,
            toolbars: [
                [
                    'fullscreen', 'source', '|', 'undo', 'redo', '|',
                    'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                    'directionalityltr', 'directionalityrtl', 'indent', '|',
                    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                    'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                    'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
                    'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
                    'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                    'print', 'preview', 'searchreplace', 'drafts', 'help'
                ]
            ]
        });

        $(".comment-edit .btn").click(function(e) {
            e.preventDefault();

            var comment = ue.getContent();
            if (comment == '') {
                Message('请输入评论内容');
                return false;
            }

            var $this = $(this);
            if ($this.hasClass("doing"))
                return;
            $this.addClass("doing");
            $.post('/topic/editcommentadd', {
                commentid:[(${comment.commentid})],
                comment: comment
            }, function(data) {
                if (data == "-1") {
                    ShowTip('评论失败');
                } else {
                    ShowTip('评论已提交');
                }
                $this.removeClass("doing");
                location = "/topic/[(${comment.topicid})]";
            });
        });

    });
</script>